package Triangulation;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import Triangulation.minimalityMetrics.MinimalityMetric;

import controller.Notification;
import controller.NotificationCenter;

import tools.ConvexHullCreator;

import datatypes.Edge;
import datatypes.Vertex;

public class ConvexHullEdgeGenerator implements EdgeGenerator {

    @Override
    public Vector<Edge> processVertices(Vertex[] points, MinimalityMetric metric) {

        List<Vertex> pointList = new ArrayList<Vertex>();
        for (Vertex vertex : points) {
            pointList.add(vertex);
        }

        Vector<Edge> returnVector = new Vector<Edge>();
        returnVector.addAll(ConvexHullCreator.getHullEdges(ConvexHullCreator.doJarvisMarch(pointList)));
        
        NotificationCenter nc = NotificationCenter.defaultNotificationCenter();
		nc.postNotification(Notification.didFinishMWT, returnVector);
        return returnVector;
    }

    @Override
    public String getName() {
        return "ConvexHull";
    }

}
